
package com.kweative.util;

import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author henrik
 */
public class Benchmark {
    private static Benchmark instance = null;
    private Date start;
    private Date last;

    public static Benchmark instance() {
        if (instance == null)
            instance = new Benchmark();
        return instance;
    }

    public void start() {
        last = new Date();
        start = new Date();
    }
    public void mark(String name) {
        Date now = new Date();
        long diff = now.getTime() - last.getTime();
        long diffTotal = now.getTime() - start.getTime();

        last = now;
        if (diff > 1)
            Logger.getLogger(Benchmark.class.getName()).log(Level.INFO,String.format("Benchmark (MS): Since Last: %s | Total: %s | %s",diff,diffTotal,name));
    }

}
